<template>
	<view class="wallet-wrap" :class="skinStyle">
		<view class="tui-mybg-box">
			<!-- <image class="bgimg" src="~@/static/img/myBack.png" mode="scaleToFill"></image> -->
			<view class="tui-header-center">
				<view class="headerRight">
					<view class="headerImg">
						<image v-if="isHaveMember=='1'||isMember=='yes'" class="crown" src="~@/static/img/crown.png"></image>
						<image :src="url" class="tui-avatar"></image>
					</view>
					<view class="tui-userMobile" v-if="customerInfo&&customerInfo.customer">
						<view class="agencyId" style="max-width: 520rpx;"
							v-if="customerInfo&&customerInfo.customer && customerInfo.customer.nickName">微信昵称：
							{{customerInfo.customer.nickName}}</text>
						</view>
						<text class="memberCodeWord">
							<text v-if="memberInfo && memberInfo.userName">{{memberInfo.userName}}</text>
							<!-- <text v-if="memberInfo && memberInfo.agencyId">会员卡号：</text> -->
							<template v-if="memberInfo&&memberInfo.agencyId">({{memberInfo.agencyId}})</template>
						</text>
					</view>
				</view>

			</view>
		</view>
		<view class="wallet-box">
			<view class="tui-box-my commission-wrap">
				<view class="commission-item" @tap="jumpTo('detail')">
					<view class="font1">{{agencyFee?agencyFee:0}}</view>
					<view class="font2">我的提成</view>
					<view class="detail-btn-wrap" >
						<view class="detail-btn"><text>明细</text><i class="triangle"></i></view>
					</view>
				</view>
				<view class="commission-item">
					<view class="font1">{{agencyFeeWithdraw?agencyFeeWithdraw:0}}</view>
					<view class="font2">可提余额</view>
				</view>
			</view>
			<view class="vipImgBox" @tap="jumpTo('apply')">
				<swiper :indicator-dots="true" indicator-color="#DDDDDD" indicator-active-color="#E96D71" :autoplay="false " :interval="5000"
				:duration="150" :circular="true" class="vipImgSwiper">
					<block v-for="(item,index) in bannerList" :key="index">
						<swiper-item :data-index="index" style="display: flex;justify-content: center;">
							<!-- <image v-if="index>=videoLength" lazy-load :src="imgSrc+item" class="tui-slide-image"/> -->
							<image class="vipImg" :src="item" mode="widthFix" @tap="jumpTo('share')"></image>
						</swiper-item>
					</block>
				</swiper>
			</view>
			<view class="tui-box-my tui-coupon-box wallet-con">
				<view class="tui-cell-header">
					<view class="tui-cell-title">常用工具</view>
				</view>
				<view class="tui-padding-dr">
					<view class="tui-order-item" @tap="jumpTo('withdraw')">
						<view class="my-cell-icon">
							<image :src="baseUrl+iconSettings['demand_withdraw']" mode="aspectFill"></image>
						</view>
						<view class="tui-order-text">我要提现</view>
					</view>
					<view class="tui-order-item" @tap="navTo('/packageB/pages/share/share', {login: true})">
						<view class="my-cell-icon">
							<image :src="baseUrl+iconSettings['demand_share']" mode="aspectFill"></image>
						</view>
						<view class="tui-order-text">我要分享</view>
					</view>
					<view class="tui-order-item" @tap="jumpTo('customers')">
						<view class="my-cell-icon">
							<image :src="baseUrl+iconSettings['my_client']" mode="aspectFill"></image>

						</view>
						<view class="tui-order-text">我的顾客</view>
					</view>

					<view class="tui-order-item" v-if="isHaveMember=='1'||isMember=='yes'" @tap="jumpTo('members')">
						<view class="my-cell-icon">
							<image :src="baseUrl+iconSettings['my_member']" mode="aspectFill"></image>
						</view>
						<view class="tui-order-text">我的会员</view>
					</view>
				</view>
			</view>
		</view>
		<foot-bar :current="selectedIndex" :skinStyle="skinStyle"></foot-bar>
		<!-- <loading></loading> -->
		<tui-modal></tui-modal>
	</view>
</template>

<script>
	import footBar from "@/components/footbar/footbar"
	import mixin from "@/utils/mixin.js"
	import {
		mapState
	} from 'vuex';
	export default {
		mixins: [mixin],
		components: {
			footBar,
		},
		data() {
			return {
				selectedIndex: 4,
				animationData: {},
				userInfo: {
					name: '',
					telphone: ''
				},
				drCodeApplyFlg: null, //是否可以申请DR会员
				bannerList:['../../static/img/vipImg.png'],
				memberInfo: {
					agencyId: '',
					userName: '',
					customerUserId: ''
				}, //会员信息
				agencyFee: '',
				agencyFeeWithdraw: '',
				showSkinFlag: false,
				currentSkin: 0,
				url: '/static/img/mine_def_touxiang_3x.png',
				othersCouponRecommendId: '',
				customerInfo: { //用户所有信息
					customerUserId: '',
					headimgurl: '',
					nickName: '微信昵称',
					userName: '',
					customersAddressData: [

					]
				},
				isMember: '',
				orgLv: uni.getStorageSync('orgLv'),
				baseUrl: this.$store.state.imgUrl,
				isHaveMember: uni.getStorageSync('isHaveMember'),
				stopFunctionArr:[],
			}
		},
		computed: {
			...mapState(['iconSettings']),
		},
		onLoad() {
			// #ifdef H5
			this.$wechat.noShare();
			// #endif
			//经销商及以上
			// this.isHaveMember===1||
			if (uni.getStorageSync('orgLv') !== 'gk'&&uni.getStorageSync('orgLv') !== 'hy'&&uni.getStorageSync('orgLv') !== 'dxy') { //不用true,false,防止界面闪现
				this.isMember = 'yes'
			} else {
				this.isMember = 'no'
			}
			
			this.getCustomerInfo();
			this.getMemberInfo();
			this.getAgencyFee();
			// 获取图标设置信息
			this.$util.getIconSetting();
			this.stopFunctionArr = this.$store.state.dictDataAll['stopFunction'];
		},
		methods: {
			getCustomerInfo() { //获取用户信息
				let params={
					type:1,
				}
				this.$http.customersIncipient(params).then((res) => {
					if (res.status === 0) {
						this.customerInfo = res.data;
						this.url = res.data.customer.headimgurl;
					}
				})
			},
			getMemberInfo() { //获取会员码和姓名
				this.$http.getMemberInfo().then((res) => {
					if (res.status === 0) {
						this.memberInfo = res.data;
					}
				})
			},
			getAgencyFee() { //获取提成
				this.$http.getAgencyFee().then((res) => {
					if (res.status === 0) {
						this.agencyFee = res.data.agencyFee;
						this.agencyFeeWithdraw = res.data.agencyFeeWithdraw;
					}
				})
			},
			jumpTo(type) {
				if (type === 'detail') {
					let stopFunItem1 = null; //当前对象
					let stopFunItem2 = null; //message对象
					let stopFunItemArr = this.stopFunctionArr.filter((item) => {
						return (item.dictLabel == 'function10' || item.dictLabel ==
							'message')
					});
					if (stopFunItemArr[0].dictLabel == 'function10') {
						stopFunItem1 = stopFunItemArr[0];
						stopFunItem2 = stopFunItemArr[1];
					} else {
						stopFunItem2 = stopFunItemArr[0];
						stopFunItem1 = stopFunItemArr[1];
					}
					
					if (stopFunItem1.dictValue == '0') { //开启
					
						uni.navigateTo({
							url: '/packageB/pages/withdraw/moneyDetail?customerUserId=' + this.customerInfo.customerUserId
						})
					} else { //关闭
						let titleTips = stopFunItem2.dictValue
						uni.showToast({
							icon: 'none',
							title: titleTips,
							duration: 2000,
						})
					}
				} else if (type === 'customers') {
					
					let stopFunItem1 = null; //当前对象
					let stopFunItem2 = null; //message对象
					let stopFunItemArr = this.stopFunctionArr.filter((item) => {
						return (item.dictLabel == 'function7' || item.dictLabel == 'message')
					});
					if (stopFunItemArr[0].dictLabel == 'function7') {
						stopFunItem1 = stopFunItemArr[0];
						stopFunItem2 = stopFunItemArr[1];
					} else {
						stopFunItem2 = stopFunItemArr[0];
						stopFunItem1 = stopFunItemArr[1];
					}
					if (stopFunItem1.dictValue == '0') { //开启
						uni.navigateTo({
							//url:'/packageB/pages/customers/customers?nickName='+this.customerInfo.nickName
							url: '/packageB/pages/customers/customers'
						})
					} else { //关闭
						let titleTips = stopFunItem2.dictValue
						uni.showToast({
							icon: 'none',
							title: titleTips,
							duration: 2000,
						})
					}
					
				} else if (type === 'members') {
					let stopFunItem1 = null; //当前对象
					let stopFunItem2 = null; //message对象
					let stopFunItemArr = this.stopFunctionArr.filter((item) => {
						return (item.dictLabel == 'function8' || item.dictLabel == 'message')
					});
					if (stopFunItemArr[0].dictLabel == 'function8') {
						stopFunItem1 = stopFunItemArr[0];
						stopFunItem2 = stopFunItemArr[1];
					} else {
						stopFunItem2 = stopFunItemArr[0];
						stopFunItem1 = stopFunItemArr[1];
					}
					if (stopFunItem1.dictValue == '0') { //开启
						uni.navigateTo({
							//url:'/packageB/pages/customers/members?nickName='+this.customerInfo.nickName
							url: '/packageB/pages/customers/members'
						})
					} else { //关闭
						let titleTips = stopFunItem2.dictValue
						uni.showToast({
							icon: 'none',
							title: titleTips,
							duration: 2000,
						})
					}
				} else if (type === 'withdraw') {
					if (this.agencyFeeWithdraw) {
						uni.navigateTo({
							url: `/packageB/pages/withdraw/withdraw?agencyFeeWithdraw=${this.agencyFeeWithdraw}`
						})
					} else {
						uni.navigateTo({
							url: '/packageB/pages/withdraw/withdraw'
						})
					}

				}else if (type === 'share') {
					uni.navigateTo({
						url: '/packageB/pages/share/share'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.wallet-wrap {
		padding-top: 345rpx;
		height: 100vh;
		position: relative;

		.tui-info {
			width: 100%;
			// padding-left: 30rpx;
			color: #fff;
			box-sizing: border-box;
			display: flex;
			margin-top: 12rpx;
			// align-items: center;
			justify-content: center;
			height: 32rpx;
		}

		.wallet-box {
			width: 100%;
			// min-height: calc(100vh - 300rpx);
			box-shadow: 0 3rpx 20rpx rgba(183, 183, 183, 0.1);
			border-radius: 50rpx 50rpx 0 0;
			position: absolute;
			left: 0;
			top: 290rpx;
			z-index: 100;
			background: #f7f7f7;
		}
		

		.commission-wrap {
			height: 244rpx;
			width: 100%;
			padding: 40rpx 80rpx 50rpx;
			display: flex;
			justify-content: space-between;
			color: #fff;
			border-bottom: 16rpx solid $bg;
			// position: absolute;
			// top: 300rpx;
			.commission-item {
				width: 300rpx;
				text-align: center;
				position: relative;
				color: #111;
				
				.font1 {
					font-size: 48rpx;
					margin-bottom: 8rpx;
					font-weight: bold;
				}

				.font2 {
					font-size: 28rpx;
				}

				.detail-btn-wrap {
					padding: 10rpx;
				}

				.detail-btn {
					border: 2rpx solid $red;
					-webkit-background-clip: text;
					width: 90rpx;
					height: 32rpx;
					border-radius: 16rpx;
					position: absolute;
					bottom: -16rpx;
					left: 50%;
					margin-left: -50rpx;
					color: $red;
					display: flex;
					font-size: 20rpx;
					justify-content: space-around;
					align-items: center;
					opacity: 0.8;
					text {
						display: inline-block;
						padding-left: 10rpx;
					}

					i {
						display: inline-block;
						width: 0;
						height: 0;
						border: 8rpx solid;
						border-color: transparent transparent transparent $red;
					}
				}
			}
		}

		// .iconbg1{
		// 	background: linear-gradient(135deg,#84fab0,#8fd3f4);
		// }
		// .iconbg2{
		// 	background: linear-gradient(135deg,#a1c4fd,#c2e9fb);
		// }
		// .iconbg3{
		// 	background: linear-gradient(135deg,#ff9a9e,#fecfef);
		// }
		// .iconbg4{
		// 	background: linear-gradient(135deg,#f6d365,#fda085);
		// }
		// .iconbg5{
		// 	background: linear-gradient(135deg,#ff0844,#ffb199);
		// }
		.tui-cell-sub {
			font-size: 26rpx;
			font-weight: 400;
			color: #999;
			padding-right: 28rpx;
		}



	}

	.tui-box {
		width: 100%;
		background: #fff;
		box-shadow: 0 3rpx 20rpx rgba(183, 183, 183, 0.1);
		border-radius: 50rpx 50rpx 0 0;
		padding-top: 20rpx;
		overflow: hidden;
	}


	.tui-mybg-box {
		width: 100%;
		height: 42%;
		// background-image: url(~@/static/img/myBack.png) no-repeat;
		// background: url('../../static/img/myBack.png') no-repeat;
		background-image:linear-gradient(to right,#E5E7EF,#F2F3F7);
		background-size: 100% 100%;
		position: absolute;
		left: 0;
		top: 0;
		box-sizing: border-box;

		.bgimg {
			width: 100%;
			height: 100%;
			position: absolute;
			left: 0;
			right: 0;
			top: 0;
			bottom: 0;
			z-index: -1;
		}
	}

	.tui-box-my {
		width: 100%;
		background: #fff;
		box-shadow: 0 3rpx 20rpx rgba(183, 183, 183, 0.1);
		border-radius: 50rpx 50rpx 0 0;
		padding-top: 20rpx;
		overflow: hidden;
	}

	.my-container .tui-content-mybox {
		width: 100%;
		// padding: 0 16rpx;
		box-sizing: border-box;
		position: relative;
		top: 0rpx;
		z-index: 10;
	}

	.tui-header-center {
		width: 100%;
		height: 120rpx;
		margin-top: 100rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		display: flex;
		// align-items: center;
		justify-content: space-between;
		align-items: center;

		.headerImg {
			position: relative;
			.tui-avatar{
				box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.12);
			}
			
			.crown {
				width: 100rpx;
				height: 60rpx;
				position: absolute;
				top: -44rpx;
				left: 50%;
				margin-left: -50rpx;
				z-index: 10;
			}
		}

	}
//不能提出，会影响订单样式
	.tui-coupon-box {
			border-radius: 0 !important;
		}
	
		.tui-padding-dr {
			width: 100%;
			// height: 130rpx;
			padding: 20rpx 10rpx;
			box-sizing: border-box;
			overflow: hidden;
		}
	
		.tui-order-item {
			width: 25%;
			display: flex;
			flex-direction: column;
			align-items: center;
			float: left;
		}
	
		.tui-icon-box {
			position: relative;
		}
	
		.tui-order-icon {
			width: 52rpx;
			height: 52rpx;
			font-size: 46rpx;
			display: block;
			color: #ea655e;
		}
	
		.tui-order-text,
		.tui-tool-text {
			font-size: 26rpx;
			font-weight: 400;
			color: #111;
			padding-top: 15rpx;
		}
	
		.tui-tool-text {
			font-size: 24rpx;
		}
		.headerRight {
			display: flex;
			justify-content: center;
			align-items: center;
		}
		.memberCodeWord{
			text{
				display: inline-block;
				margin-right: 6rpx;
			}
		}
	.vipImgBox {
		width: 100%;
		height: 230rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: $bg;
		padding-top:8rpx;
		.vipImg {
			width: 90%;
		}
	}
	.vipImgSwiper{
		width: 100%;
		height: 100%;
	}
</style>
